package com.hanggold.springboot.lesson3.controller;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.method.HandlerMethod;
import org.springframework.web.servlet.mvc.method.RequestMappingInfo;
import org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping;

import java.util.Map;

/**
 * @author <a href="mailto:sunmch@163.com">smc</a>
 * @date 2019-07-11 22:28
 * @since
 **/
@RestController
@RequestMapping("mappings")
public class MappingController {

    private static final Log log = LogFactory.getLog(MappingController.class);

    @Autowired
    private RequestMappingHandlerMapping requestMappingHandlerMapping;

    @RequestMapping(value = "init",method =RequestMethod.GET )
    public Object mappings(){

        Map<RequestMappingInfo, HandlerMethod> methodMap =  requestMappingHandlerMapping.getHandlerMethods();
        methodMap.forEach((key,val)->{
            System.out.println("Mapped " + key + " onto " + val);
        });
        return "xxx";
    }

}
